//grab natural resource stuff from lee and lin paper
use "$data\Amenities\Lee_lin\Supplementary\data\Lee_Lin_data", clear
keep if year == 2000
keep statefips tr_pop d2shore
replace d2shore = d2shore/100000
ren statefips stfips
merge m:1 stfips using "$data/Crosswalks/state_div_crosswalk", keep(match) nogen
collapse (mean) d2shore [w=tr_pop], by(div)
save "$temp/div_shores", replace

//grab other stuff from diamond paper
use "$data/Crosswalks/cbsatocountycrosswalk", clear
keep state msa
keep if length(msa) == 4
destring msa, replace
duplicates drop msa, force
replace msa = msa/10
save "$temp/msa_xwalk", replace


//run diamond replication file
do "$data/Amenities/Diamond/replication/diamond_replicate"

use "$temp/diamond_amenities", clear
merge m:1 msa using "$temp/msa_xwalk", keep(match) nogen
merge m:1 state using "$data/Crosswalks/state_fips_crosswalk", keep(match) nogen
ren statefips stfips
merge m:1 stfips using "$data/Crosswalks/state_div_crosswalk", keep(match) nogen
collapse (mean) amen_index [w=pop_all], by(div)
set obs 9
replace div = 1 if div == .
su amen
replace amen = 0.8 if amen == .
save "$temp/div_amens", replace

//temperature from kennan
import delimited "$data/Amenities/cooling.csv", clear
keep v11 v9
ren v9 cooling 
ren v11 state_full
replace state_full = subinstr(state_full, "_", " ", .)
replace state_full = strproper(state_full)
merge 1:1 state_full using "$data/Crosswalks/state_fips_crosswalk", keep(match) nogen
replace cooling = cooling/1000
keep cooling statefips
save "$temp/state_weather", replace
ren statefips stfips
merge 1:1 stfips using "$data/Crosswalks/state_div_crosswalk", keep(match) nogen
collapse (mean) cooling, by(division)
save "$temp/div_cooling", replace

//add together and add to div characteristic file
use "$temp/div_shores", clear
merge 1:1 div using "$temp/div_amens", keep(match) nogen
merge 1:1 div using "$temp/div_cooling", keep(match) nogen
ren division div
save "$temp/div_amenities", replace
